<%@ page contentType="text/html;charset=GBK" %>
<%@ page import="java.util.*" %>
<%@ page import="com.ionglobal.db.*" %>
<%@ page import="com.ionglobal.lib.*" %>
 
<%@ include file="../init_include.jsp" %>
 <%
	int pageid = 0;
	int pagerows = 10;
	int totalrows = 0;
	int totalpages = 1;
	String orderby = "id";
	String orderby2 = "asc";
	String temp = "";
	String sql = "";
	
	temp=request.getParameter("pageid");
	if( temp != null && temp.trim().length() > 0)
		pageid=Integer.parseInt(temp);

	temp=request.getParameter("orderby");
	if( temp != null && temp.trim().length() > 0)
		orderby=temp.trim();

	temp=request.getParameter("orderby2");
	if( temp != null && temp.trim().length() > 0)
		orderby2=temp.trim();
	
	temp=request.getParameter("pagerows");
	if( temp != null && temp.trim().length() > 0){
		pagerows = Integer.parseInt(temp);
		if( pagerows <=0 ) pagerows = 10;
		//session.setAttribute("pagerows",temp);
	}

	String name = "";
	String parentid = "";
	String descript = "";
	String layer = "";
	String code_pre = "";
	String classcode = "";
	int id=0;


	name = request.getParameter("name");
	classcode = request.getParameter("classcode");
	parentid = request.getParameter("parentid");
	descript = request.getParameter("descript");
	layer = request.getParameter("layer");
	code_pre = request.getParameter("code_pre").trim();
	code_pre=dbi.fixSql(code_pre);
	if(code_pre==null || code_pre.length()==0)
		code_pre="|";
	if(request.getParameter("id")!=null)
		id=Integer.parseInt(request.getParameter("id")); 	
 	if(id!=0) {
/*
 		sql = "update sys_class set ";
		sql = sql + "name='"+ dbi.fixSql(name) +"', ";
		sql = sql + "parentid=" + parentid +", ";
		sql = sql + "descript = "+ dbi.setLargeTextField( descript) + ", ";
		sql = sql + "layer=" + layer +"" + " where id=" + id;
		dbi.execute( sql );
		dbi.updateLargeTextField( "sys_class"," where id="+ id, "descript",descript );	
*/
 		sql = "update sys_class set ";
		sql = sql + "name='"+ dbi.fixSql(name) +"', ";
		sql = sql + "classcode='"+ dbi.fixSql(classcode) +"', ";
		sql = sql + "parentid=" + parentid +", ";
		sql = sql + "descript = '"+ descript + "', ";
		sql = sql + "layer=" + layer +"" + " where id=" + id;
		dbi.execute( sql );

 	} else {
		long newid = SequenceManager.getNextValue( dbi,"sys_class_seq");	
/*
 		sql = "insert into sys_class (id, name,code,parentid,descript,layer) values (";
		sql = sql + newid +", ";
		sql = sql + "'"+ dbi.fixSql(name) +"', ";
		sql = sql + "'"+ code_pre +newid+"|', ";
		sql = sql + parentid +", ";
		sql = sql +  dbi.setLargeTextField(descript) + ", ";
		sql = sql + layer +")";
 
		dbi.execute( sql );
		dbi.updateLargeTextField( "sys_class"," where id="+ newid, "descript",descript );	
*/
 		sql = "insert into sys_class (id, name, classcode, code, parentid, descript, layer) values (";
		sql = sql + newid +", ";
		sql = sql + "'"+ dbi.fixSql(name) +"', ";
		sql = sql + "'"+ dbi.fixSql(classcode) +"', ";
		sql = sql + "'"+ code_pre +newid+"|', ";
		sql = sql + parentid +", '";
		sql = sql + descript + "', ";
		sql = sql + layer +")";
 
		dbi.execute( sql );
	} 	
 %>
<script Language="JavaScript" src="../script/Ion_Show.js"></script> 
<script language="javascript">
	closewindow(0);
</script>	
<%@ include file="../init_free.jsp" %>  